<template>
  <div>
    <h2>我总共有{{ moneycount }}元</h2>
    <input type="checkbox" :checked="flag" />有钱人?
    <h3>目前的状态: {{ moneycount > 10000 ? '有钱人' : '穷光蛋' }}</h3>
    <button @click="eat">吃饭花了-100</button>
    <button @click="foot">洗脚花了-60</button>
    <button @click="Appointment">约会花了-1000</button>
    <button @click="givewaimai">送外卖挣了+100</button>
  </div>
</template>

<script>
export default {
  name: 'xiao-anli',
  data() {
    return {
      flag: true,
      moneycount: 10000,
    }
  },
  methods: {
    eat() {
      //通过this修改数据
      this.moneycount -= 100
      this.flag = this.moneycount >= 10000 ? true : false
    },
    foot() {
      this.moneycount -= 60
      this.flag = this.moneycount >= 10000 ? true : false
    },
    Appointment() {
      this.moneycount -= 1000
      this.flag = this.moneycount >= 10000 ? true : false
    },
    givewaimai() {
      this.moneycount += 100
      this.flag = this.moneycount >= 10000 ? true : false
    },
  },
}
</script>

<style></style>
